package org.example.Map;

import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

public class Test {


    public static void main(String[] args) {
        Map<Integer,String> map = new HashMap<>();
        Map<Integer,String> Testmap = new HashMap<>();
        map.put(2,"ban");
        String apple = map.put(2, "apple");
        System.out.println(apple);
        map.put(2,"beer");
        map.put(3,"tiger");
        map.put(4,"berry");
        map.put(null,"Test1");
        map.put(null,"Test2");
        System.out.println(map.get(null));

        System.out.println(map.get(0));

        Testmap.putAll(map);


        map.forEach(new BiConsumer<Integer, String>() {
            @Override
            public void accept(Integer integer, String s) {
                System.out.println(integer + s);
            }
        });
        System.out.println("============================");

        map.forEach((integer,s)->{
            System.out.println("K:" + integer + " V: " + s);
        });

        Set<Integer> set = map.keySet();
        Iterator it = set.iterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }

        Collection<String> values = map.values();
        Iterator<String> iterator = values.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }

        Set<Map.Entry<Integer,String>> entrySet =  map.entrySet();
        Iterator<Map.Entry<Integer, String>> iterator1 = entrySet.iterator();
        while (iterator1.hasNext()){
            System.out.println(iterator1.next());
        }
        System.out.println("aaa");


//        for(){
//
//        }
    }
}
